//
// Created by konglinglong on 2020/9/4.
//

#ifndef CSP_INCLUDE_UTILS_MISC_H
#define CSP_INCLUDE_UTILS_MISC_H

#include "commDef.h"

#ifdef __cplusplus
extern "C"
{
#endif

extern uint64_t gCspCpuFreqHz;
extern uint64_t gCspCpuFreqKHz;
extern uint64_t gCspCpuFreqMHz;
extern double   gCspCpuFreqGHz;
void CSP_InitCpuFreqVar(void);

int32_t CSP_Bin2Hex(const char* src, uint32_t srcLen, char* dst, uint32_t dstLen);
void CSP_DelayStrictUs(uint64_t *timeStamp, uint64_t delayUs);
int32_t CSP_ArrivalDelayTimeUs(uint64_t *lastTimeStamp, uint64_t delayUs);
uint32_t CSP_FastLog2Uint(uint64_t n);
uint32_t CSP_FastLog10Uint(uint64_t n);
double CSP_FastLog2Float(double x);
double CSP_FastLog10Float(double x);

#define LOG2X_TABLE_SIZE 513
extern const uint8_t gLog2xTable[];

#ifdef __cplusplus
}
#endif

#endif //CSP_INCLUDE_UTILS_MISC_H
